package com.yuelao.hive;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Description
 *
 * @author fengliye
 * @version v1.0
 * @date 2019/11/13 17:47
 * @modify detail
 * 版本       修改人        修改时间      修改内容描述
 * ---------------------------------------------
 * <p>
 * ---------------------------------------------
 */
public class HiveDemo {
    private static String driverName = "org.apache.hive.jdbc.HiveDriver";

    public static void main(String[] args) {

        try {
            // Register driver and create driver instance
            Class.forName(driverName);

            // get connection
            Connection con = DriverManager.getConnection("jdbc:hive://150.109.109.100:10000/mytest", "", "");

            // create statement
            Statement stmt = con.createStatement();

            // execute statement
            stmt.executeQuery("CREATE TABLE IF NOT EXISTS "
                    +" employee ( eid int, name String, "
                    +" salary String, destignation String)"
                    +" COMMENT ‘Employee details’"
                    +" ROW FORMAT DELIMITED"
                    +" FIELDS TERMINATED BY ‘\t’"
                    +" LINES TERMINATED BY ‘\n’"
                    +" STORED AS TEXTFILE;");

            System.out.println("");
            con.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


}
